package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * cleverClinic
 * com.herench.bs.handler
 *
 * @author wangwenkai
 * @date 2018/1/4/16:21
 * 添加收藏
 */
@Component
@Handler(code = "100601" ,name="添加收藏")
public class AddEnshrineHandler extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        Assert.hasLength(channelCode, "sysCode 为空");
        String user = requestMessage.getArgsPropertyStringValue("user");
        Assert.hasLength(user, "user 为空");
        String collectType = requestMessage.getArgsPropertyStringValue("collectType");
        Assert.hasLength(collectType, "collectType 为空");
        String collectContent = requestMessage.getArgsPropertyStringValue("docId");
        Assert.hasLength(collectContent, "collectContent 为空");
        IPersonAgent agent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String, Object> res = agent.addEnshrine(channelCode,user,collectType, collectContent);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        return responseMessage;
    }

}
